<?php
//控制器

class register extends mysql{
    function usereg(){
        if(!empty($_POST)){
            $name = $_POST['username'];
            $pwd = $_POST['password'];
            $select_sql = 'select username from user_table where username ="'.$name.'"';
            $sql_q = $this->select_one($select_sql);
            if(empty($sql_q)){
//'INSERT INTO test_table (`username`, `password`) VALUES ("'.$name.'","'.$pwd.'");';
                $data = array(
                    'username' => $name,
                    'password' => $pwd
                );
                $table = 'user_table';
                $this->insert($data, $table);
                $this->success(1,'index','login','userlogin','注册成功，立即登录。');
            }else{
                $this->fail(1,'index','register','usereg','用户名已存在！');
            }
        }

        $this->display('index','index','register',['url' => $this->config]);
    }

}